package com.atguigu.gmall.order.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.model.vo.order.OrderConfirmVo;

import com.atguigu.gmall.order.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/9/12 15:46
 */
@RestController
@RequestMapping("/rpc/inner/order")
public class RpcOrderController {
    @Autowired
    OrderInfoService orderInfoService;
    @GetMapping("/orderList")
    public Result<OrderConfirmVo> orderList() {
        OrderConfirmVo orderConfirmVo=orderInfoService.orderConfirm();
        return Result.ok(orderConfirmVo);
    }
    @GetMapping("/infoByOrderId")
    public Result<OrderInfo> infoById(@RequestParam("orderId") Long orderId) {
        OrderInfo orderInfo=orderInfoService.infoById(orderId);
        return Result.ok(orderInfo);
    }

    @GetMapping("/updateOrderStatusToPaid/{outTradeNo}")
    public Result updateOrderStatusToPaid(@PathVariable("outTradeNo") String outTradeNo) {
        orderInfoService.updateOrderStatusToPaid(outTradeNo);
        return Result.ok();
    }

    @GetMapping("/checkOrderStatusByAliPay/{outTradeNo}")
    public Result checkOrderStatusByAliPay(@PathVariable("outTradeNo") String outTradeNo) {
        orderInfoService.checkOrderStatusByAliPay(outTradeNo);
        return Result.ok();
    }
}
